/***********************************************
 This file is part of redia-bapps-main-ios.
 
 Copyright (c) 2015 Redia A/S
 
 Redia-bapps-main-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-bapps-main-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-bapps-main-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

//
//  BAOpeningHoursLibraryCell.m
//  redia-bapps-ios
//
//  Created by Henrik Lynbech on 05/11/13.
//  Copyright (c) 2013 redia. All rights reserved.
//

#import "BAOpeningHoursLibraryCell.h"
#import <QuartzCore/QuartzCore.h>
#import "BALibrarySettings.h"

@interface BAOpeningHoursLibraryCell ()

@property (weak, nonatomic) IBOutlet UIView *colorDotView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *rightArrowImageView;
@property (weak, nonatomic) IBOutlet UIImageView *openingHoursBackground;
@property (weak, nonatomic) IBOutlet UIView *highlightView;
@property (weak, nonatomic) IBOutlet UIView *selectedView;

@end

@implementation BAOpeningHoursLibraryCell

-(void)awakeFromNib
{
    BA_LABEL_SET_FONT_REGULAR(self.titleLabel);
    self.colorDotView.layer.cornerRadius = 5;

}

-(void)setLibrary:(BAOpeningHoursLibrary *)lib lightBackground:(BOOL)isLightBg
{
    self.titleLabel.text = lib.name;
    UIColor* greenColor = [UIColor colorWithRed:91.0/255.0 green:218.0/255.0 blue:112.0/255.0 alpha:1];
    self.colorDotView.backgroundColor = lib.isOpen ? greenColor : [UIColor redColor];
    self.openingHoursBackground.image = isLightBg ? [UIImage imageNamed:@"opening-cell-bg-light"] : [UIImage imageNamed:@"opening-cell-bg-dark"];
    
    self.rightArrowImageView.image = [[BALibrarySettings instance] getCachedImageNamed:@"arrow-right-smalldisclose"
                                                                     multiplyWithColor:[[BALibrarySettings instance] getCustomerColorNormal]];
}


-(void)setHighlighted:(BOOL)highlighted{
    [self setHighlighted:highlighted animated:NO];
}

-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    [self.highlightView setHidden:!highlighted];
    [super setHighlighted:highlighted animated:animated];
}

-(void)setSelected:(BOOL)selected
{
    [self setSelected:selected animated:NO];
}

-(void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    if (RD_IS_IPAD) {
        [self.selectedView setHidden:!selected];
        [super setSelected:selected animated:animated];
    }
}
@end
